package com.dp.appi;

import com.dp.appi.interceptor.APPInterceptor;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import org.springframework.boot.context.embedded.MultipartConfigFactory;

import javax.servlet.MultipartConfigElement;

/**
 * Created by xiaoji on 2015/3/17.
 */
@Configuration
@ComponentScan
@EnableAutoConfiguration
//@EnableRedisHttpSession(maxInactiveIntervalInSeconds = 60)
public class Application extends WebMvcConfigurerAdapter {

    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }

    /**
     *
     * 配置拦截器
     * @param registry
     */
    public void addInterceptors(InterceptorRegistry registry) {
        super.addInterceptors(registry);
        registry.addInterceptor(new APPInterceptor()).excludePathPatterns("/oauthControl/**","/systemControl/sysType/**","/systemControl/sysVersion/**","/systemControl/sendIdentCode/**","/codesetControl/wireList",
                "/payControl/aliNotifyUrl", "/payControl/wxNotifyUrl");
    }

    @Bean
    public MultipartConfigElement multipartConfigElement() {
        MultipartConfigFactory factory = new MultipartConfigFactory();
        factory.setMaxFileSize("1280000KB");
        factory.setMaxRequestSize("1280000KB");
        return factory.createMultipartConfig();
    }
}